<template>
	<view><!--报警详情-->
		
		<view class="feedback">
			<view class="info">报警人：<text>{{detail.objectName}}</text></view>
			<view class="info">报警类型：<text>{{detail.notificationName}}</text></view>
			<view class="info">报警明细：<text>{{detail.message}}</text></view>
			<view class="info">详细地址：<text>{{detail.address}}</text></view>
		</view>
		
			
		<view class="userbtn">
			<view class="btn btn1" @tap="backPage">取消</view>
			<view class="btn btn2" @tap="del">删除</view>
		</view>
		
	</view>
</template>

<script>
	import {
			mapState,mapGetters
		} from 'vuex';
	export default {
			computed:{
					...mapState(['user']),
				},
		data() {
			return {
				id:"",
				imei:"",
				detail:{},
			}
		},
		onLoad(e){
			this.id = e.id;
			if(e.imei){
				this.imei = e.imei;
			}
			this.getDetail();
		},
		methods: {
			del(){
				if(this.user.userInfo.personAuthen){
					uni.showModal({
						title: '提示',
						content: '确定删除？',
						cancelText: "取消", // 取消按钮的文字  
						confirmText: "确认", // 确认按钮的文字  
						showCancel: true, // 是否显示取消按钮，默认为 true
						confirmColor: '#f55850',
						cancelColor: '#39B54A',
						success: (res) => {
						if(res.confirm) {  
							this.$http.clearAlarm({id:this.id}).then(res=>{
								if(res.code==0){
									this.$tools.msg("删除成功");
									setTimeout(res=>{
										this.backPage()
									},2000)
								}
							})
							
						} else {  
							console.log('cancel') //点击取消之后执行的代码
						}  
						} 
					})
					
				}else{
					this.$tools.msg("您还没认证，请先认证")
					setTimeout(res=>{
						uni.navigateTo({
							url: '/pages/user/authentication',
							success: res => {},
							fail: () => {},
							complete: () => {}
						});
					},2000)
					
				}
			},
			backPage(){
				uni.navigateTo({
					url:"/pages/alarm/alarm?id="+this.imei
				})
			},
			getDetail(){
				this.$http.alarmDetail({id:this.id}).then(res=>{
					if(res.code==0){
						this.detail=res.alarm;
					}
				})
			}
		}
	}
</script>

<style scoped>
	.feedback{
		padding:30rpx 30rpx;
		color:#999999;
		line-height:53rpx;
	}
	.feedback .info{
		padding:30rpx 0rpx;
		border-bottom: 1rpx solid #dcdcdc;
	}
	.feedback .info text{color: #111;}

	
</style>
